package me.zxc.utils;

/**
 * @author zhangxucheng
 * @version 1.0
 * @date 2022/2/14 16:15
 */
public class ValidUtil {
    /**
     * windows文件名默认不能包含的字符列表
     */
    private static final String[] invalidFilenameSymbols =
            {"\\", "/", ":", "*", "?", "\"", "<", ">", "|"};

    /**
     * 校验文件名
     * @param filename 文件名
     * @return 替换后的文件名
     */
    public static  String validateFilename(String filename) {
        // 替换非法文件名符号
        for (String invalidSymbol : invalidFilenameSymbols) {
            if (filename.contains(invalidSymbol)) {
                filename = filename.replace(invalidSymbol, " ");
            }
        }
        return filename;
    }
}
